﻿<!--
 Copyright 2013 Shawn Henry, Rob Smith, and Michael Friedman

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->
<view:AViewPage
    x:Class="OneBusAway.WP7.View.BusDirectionPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:phoneNavigation="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:data="clr-namespace:OneBusAway.WP7.ViewModel;assembly=OneBusAway.WP7.ViewModel" 
    xmlns:view="clr-namespace:OneBusAway.WP7.View;assembly=OneBusAway.WP7.View"
    xmlns:tilt="clr-namespace:ControlTiltEffect"
    tilt:TiltEffect.IsTiltEnabled="True"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource OBAForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True"
    xmlns:localControls="clr-namespace:Microsoft.Phone.Controls"
    >

    <view:AViewPage.Resources>
        <data:BusDirectionVM x:Key="ViewModel" />
        <view:VisibilityConverter x:Key="VisibilityConverter"></view:VisibilityConverter>

        <DataTemplate x:Key="RouteDirectionTemplate">
            <Grid Margin="5,0,5,20">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80" />
                    <ColumnDefinition Width="400" />
                </Grid.ColumnDefinitions>
                
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>

                <TextBlock Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" Text="{Binding Path=route.shortName}" Foreground="{StaticResource OBAForegroundBrush}" FontSize="{StaticResource PhoneFontSizeLarge}" Margin="10,0,0,0" />
                <TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding name}" Foreground="{StaticResource OBAForegroundBrush}" />
                <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding Path=route.agency.name}" FontSize="{StaticResource PhoneFontSizeSmall}" Foreground="{StaticResource OBASubtleBrush}" />
            </Grid>
        </DataTemplate>

    </view:AViewPage.Resources>

    <!--LayoutRoot contains the root grid where all other page content is placed-->
    <Grid x:Name="LayoutRoot" Background="{StaticResource OBAPrimaryBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="24,24,0,12">
            <TextBlock x:Name="PageTitle" Text="bus direction" Margin="-3,-8,0,0" Foreground="{StaticResource OBAForegroundBrush}" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentGrid" Grid.Row="1">
            <ListBox 
                x:Name="BusDirectionListBox" 
                ItemsSource="{Binding Path=RouteDirections, Source={StaticResource ViewModel}}" 
                ItemTemplate="{StaticResource RouteDirectionTemplate}" 
                SelectionChanged="BusDirectionListBox_SelectionChanged" 
                />
        </Grid>

        <localControls:PerformanceProgressBar
            VerticalAlignment="Top"
            IsLoading="{Binding Path=operationTracker.Loading, Source={StaticResource ViewModel}}"
            Foreground="{StaticResource OBALightBrush}"
            Style="{StaticResource PerformanceProgressBarStyle}"
            />

    </Grid>

</view:AViewPage>
